package 回溯;

import com.google.common.collect.Lists;

import java.math.BigDecimal;
import java.util.*;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 黄金矿工1219.java
 * @createTime 2023年02月22日 19:15:00
 */
public class 黄金矿工1219 {
	public static void main(String[] args) {
		//getMaximumGold(new int[][] {new int[] {0, 6, 0}, new int[] {5, 8, 7}, new int[] {0, 9, 0}});
		System.out.println(2^6);
		System.out.println(2>>1);
		System.out.println((2 << (3 - 1)) - 1);
		System.out.println(new BigDecimal("2.131").toPlainString());
		System.out.println(7^1);
		ArrayList<String> list = Lists.newArrayList("aca","cha","r","act","ers");
		Collections.sort(list);
		System.out.println(list);
		char[] c=new char[]{'A','B'};
		Set<Character> set=new HashSet<>();

	}

	public static int getMaximumGold(int[][] grid) {
		int result = 0;
		for (int i = 0; i < grid.length; i++) {
			for (int j = 0; j < grid[i].length; j++) {
				int temp = grid[i][j];
				backTrace(grid, temp, i, j);
				result = Math.max(result, temp);
			}
		}
		return result;
	}

	public static void backTrace(int[][] grid, int temp, int i, int j) {
		if (i < 0 || i >= grid.length || j < 0 || j > grid[0].length) {
			return;
		}
		int tempGrid = 0;
		//往左走
		if (i - 1 >= 0 && grid[i - 1][j] != 0) {
			tempGrid = grid[i - 1][j];
			grid[i - 1][j] = 0;
			backTrace(grid, temp + tempGrid, i - 1, j);
			grid[i - 1][j] = tempGrid;
		}
		//往右走
		if (i + 1 <= grid.length - 1 && grid[i + 1][j] != 0) {
			tempGrid = grid[i + 1][j];
			grid[i + 1][j] = 0;
			backTrace(grid, temp + tempGrid, i + 1, j);
			grid[i + 1][j] = tempGrid;
		}
		//往上走
		if (j - 1 >= 0 && grid[i][j - 1] != 0) {
			tempGrid = grid[i][j - 1];
			grid[i][j - 1] = 0;
			backTrace(grid, temp + tempGrid, i, j - 1);
			grid[i][j - 1] = tempGrid;
		}
		//往上走
		if (j + 1 <= grid[0].length - 1 && grid[i][j + 1] != 0) {
			tempGrid = grid[i][j + 1];
			grid[i][j + 1] = 0;
			backTrace(grid, temp + tempGrid, i, j + 1);
			grid[i][j + 1] = tempGrid;
		}
		return;
	}
}
